2.5.7.2 Version

Next to the information on licensing, the code has a mandatory

“pragma solidity version number”, where we set the version for the

compiler.

Please note that the latest version, as of December 2021, is “Version

0.8.10”. However, you will find many different Solidity sample codes

on the Internet with different version numbers. Please note that the

new versions of Solidity keep getting released from time to time,

which come with many new features as well as bug fixes. While it’s

advisable to work with the latest versions, it’s also true that some of

the previous versions might not be compatible with the future

compiler changes.

Hence, if we write “pragma solidity ^0.5.11;”, then the code would not

compile with the earlier versions of the compiler. At the same time, it

would also not compile with any version starting from 0.6.0 and

onwards. The “^” symbol ensures that the code is compiled with the

right compiler.

We can also write something like “pragma solidity >0.4.23 <0.5.0;”

which means that the code can be compiled by any version of

Solidity that falls under these two versions.

We can also write “pragma solidity pragma solidity >=0.4.0;”.

2.5.7.3 Import File

We can have an optional import statement where we can import the

other Solidity file within the current code, as follows:

import “filename”;

We can also write

import “filename” as symbolName;

While importing the other Solidity files, it’s very important to specify

the path to those files correctly. If the other file is in the same

location, then we can write the name directly. Or else, if it’s in some

other folder, then we can write something like the following: